//
//  OAAddressBookHeaderView.m
//  OA项目
//
//  Created by innofive on 2018/4/19.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAAddressBookHeaderView.h"




@implementation OAAddressBookCell
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    
    self.detailTextLabel.text = @"asdasd";
    
    
    self.textLabel.text = @"订阅号";
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        weakSelf.detailTextLabel.right = size.width- kFitW(20);
        
        weakSelf.imageView.left = kFitW(10);
        weakSelf.textLabel.left = weakSelf.imageView.right+kFitW(10);
    }];
    
}
-(void)update:(id)model forTableView:(UITableView *)tableView AtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0) {
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        self.detailTextLabel.hidden = YES;
        self.imageView.image = IMAGE(@"dingYue");
    }else
    {
        self.detailTextLabel.hidden = NO;
        self.accessoryType = UITableViewCellAccessoryNone;
        self.imageView.image = IMAGE(@"touxiang");
    }
    
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end

@interface OAAddressBook2Cell()
@property(nonatomic,strong) UILabel *number;
@end

@implementation OAAddressBook2Cell
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    UILabel *number = ({
        UILabel *l = [UILabel new];
        l.textColor = [UIColor blackColor];
        l.text = @"7";
        [view addV:l];
        l;
    });
    _number = number;
    self.textLabel.text = @"订阅号";
    WSELF(weakSelf);
   
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
       
        if (weakSelf.indexPath.section==0) {
      
            weakSelf.imageView.left = kFitW(10);
            weakSelf.textLabel.left = weakSelf.imageView.right+kFitW(10);
        }
        else
        {
            weakSelf.textLabel.left = kFitW(10);
        }
        [number sizeToFit];
        number.centerY = size.height/2;
        number.right = size.width- kFitW(30);
        
      
    }];
    
}

-(void)update:(id)model forTableView:(UITableView *)tableView AtIndexPath:(NSIndexPath *)indexPath
{
    self.indexPath =indexPath;
    
    if (indexPath.section==0) {
        self.number.hidden = YES;
        self.imageView.hidden = NO;
        self.imageView.image = IMAGE(@"dingYue");
    }else
    {
        self.number.hidden = NO;
        self.imageView.hidden = YES;
        
    }
    [self setNeedsLayout];
    
}
@end


@implementation OAAddressBook3Cell
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.imageView.image = IMAGE(@"shangImage");
 
    self.textLabel.font = kSysFont(kFitW(15));
    self.textLabel.text = @"商业资讯";
    
    self.detailTextLabel.numberOfLines = 0;
    self.detailTextLabel.font = kSysFont(kFitW(12));
    self.detailTextLabel.text = @"阿斯顿发撒发h空啊好就是佛啊睡觉哦发啊平时就看到怕看视频都卡上的皮卡视频的爬山看打扑克啊水平的爬山款斗篷卡片上看到";
    self.detailTextLabel.textColor = [UIColor blackColor];
    WSELF(weakSelf);
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        weakSelf.imageView.size = CGSizeMake(kFitW(35), kFitW(35));
        weakSelf.imageView.left = kFitW(10);
        weakSelf.imageView.top = kFitH(10);
        
        weakSelf.textLabel.height = kFitH(25);
        weakSelf.textLabel.left = weakSelf.imageView.right+kFitW(10);
        weakSelf.textLabel.top = kFitH(10);
        
        weakSelf.detailTextLabel.size = CGSizeMake(size.width-weakSelf.imageView.right-2*kFitW(10),size.height-weakSelf.textLabel.bottom+kFitH(10));
        weakSelf.detailTextLabel.left = weakSelf.imageView.right+kFitW(10);
        weakSelf.detailTextLabel.top = weakSelf.textLabel.bottom+kFitH(10);
        
        
    }];
    
}

-(void)update:(id)model forTableView:(UITableView *)tableView AtIndexPath:(NSIndexPath *)indexPath
{
    self.indexPath =indexPath;
//    NSLog(@"%@",self.detailTextLabel);
    
}
@end

@implementation OAAddressBook4Cell
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    
    self.backgroundColor = [UIColor clearColor];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel *timer = ({
        UILabel *l = [UILabel new];
        l.textColor = [UIColor blackColor];
        l.textAlignment= NSTextAlignmentCenter;
        l.text = @"2018-10-30";
        l.font = kSysFont(kFitW(13));
        [view addV:l];
        l;
    });
    
    UIView *vbgView = ({
        UIView *l = [UIView new ];
        l.backgroundColor = [UIColor whiteColor];
        l.cornerRadius = kFitW(6);
        l.masksToBounds = YES;
        l.borderWidth = 0.5;
        l.borderColor = [UIColor blackColor];
        [view addV:l];
        l;
    });
    
    
    UILabel *label = ({
        UILabel *l = [UILabel new];
        l.textColor = [UIColor blackColor];
        l.numberOfLines = 0;
        l.text = @"ajsdiojaoidjeiowfhjiojoajsciojewiojfioejfwojeaiowfjjj";
        l.font = kSysFont(kFitW(13));
        [vbgView addV:l];
        l;
    });
    
    
    UIImageView *imageView = ({
        UIImageView *l = [UIImageView new];
        l.image = IMAGE(@"imageV");
        l.cornerRadius = kFitW(6);
        l.masksToBounds = YES;
        [vbgView addV:l];
        l;
    });
    
    
    UILabel *label1 = ({
        UILabel *l = [UILabel new];
        l.textColor = [UIColor blackColor];
        l.numberOfLines = 0;
        l.text = @"casdaswdkjaq9kqwdopkqw-[dkqop[wkdopakqwdkaopwfopakwefopkopqefwkaeowpfk";
        l.font = kSysFont(kFitW(11));
        [vbgView addV:l];
        l;
    });
    
    UIView *line = ({
        UIView *l = [UIView new ];
        l.backgroundColor = [UIColor blackColor];
        [vbgView addV:l];
        l;
    });
    
    UILabel *label2 = ({
        UILabel *l = [UILabel new];
        l.textColor = [UIColor blackColor];
        l.text = @"查看全文";
        l.font = kSysFont(kFitW(11));
        [vbgView addV:l];
        l;
    });
    
    UIImageView *jiantou = ({
        UIImageView *l = [UIImageView new];
        l.image = IMAGE(@"jiantou");
        [vbgView addV:l];
        l;
    });
    
    
    
    
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
      
        [timer sizeToFit];
        timer.centerY = kFitH(15);
        timer.centerX = size.width/2;
        
        vbgView.frame = CGRectMake(kFitW(10), kFitH(30), size.width-2*kFitW(10), size.height-kFitH(30));
        label.frame = CGRectMake(kFitW(10), kFitH(10), vbgView.width-2*kFitW(10), kFitH(35));
        imageView.frame = CGRectMake(kFitW(10), label.height + kFitH(10), vbgView.width-2*kFitW(10), kFitH(125));
        label1.frame =CGRectMake(kFitW(10),imageView.bottom+kFitH(10), vbgView.width-2*kFitW(10), kFitH(35));
        line.frame = CGRectMake(kFitW(10), label1.bottom+kFitH(5),vbgView.width-2*kFitW(10),0.5);
        
        [label2 sizeToFit];
        label2.left = kFitW(10);
        label2.top =line.bottom+kFitH(10);
        
        [jiantou sizeToFit];
        jiantou.right =vbgView.width-kFitW(10);
        jiantou.centerY =label2.centerY;
        
    }];
    
}

-(void)update:(id)model forTableView:(UITableView *)tableView AtIndexPath:(NSIndexPath *)indexPath
{
    self.indexPath =indexPath;
    //    NSLog(@"%@",self.detailTextLabel);
    
}
@end


@implementation OAAddressBook5Cell
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    
}

-(void)update:(NSDictionary *)model forTableView:(UITableView *)tableView AtIndexPath:(NSIndexPath *)indexPath
{
    self.indexPath =indexPath;
    
    self.imageView.image = IMAGE(model[@"imageName"]);
    self.textLabel.text = model[@"title"];
}
@end






@implementation OAAddressBookHeaderView
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtSection:(NSInteger)section
{
    self.textLabel.textColor = [UIColor blackColor];
    self.textLabel.text = @"C";
}
-(void)update:(id)model forTableView:(UITableView *)tableView AtSection:(NSInteger)section
{
    self.backgroundColor = hexCOLOR(@"EEEEEE");
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end

